package com.qbm.association.service.impl;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.qbm.association.entity.AdministratorS;
import com.qbm.association.mapper.AdministratorSMapper;
import com.qbm.association.service.AdministratorSService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Aron
 * @since 2021-12-12
 */
@Service
public class AdministratorSServiceImpl extends ServiceImpl<AdministratorSMapper, AdministratorS> implements AdministratorSService {
    @Autowired
    AdministratorSMapper administratorSMapper;
    @Override
    public void add(Map<String, Object> para) {
        AdministratorS administratorS = new AdministratorS();
        administratorS.setId((Integer) para.get("id"));
        administratorS.setName((String) para.get("name"));
        administratorS.setPassword((String) para.get("password"));
        administratorS.setPhone((String) para.get("phone").toString());
        administratorS.setSex((String) para.get("sex"));
        administratorS.setMajor((String) para.get("major"));
        administratorSMapper.insert(administratorS);
    }

    @Override
    public void modify(Map<String, Object> para) {
        AdministratorS administratorS2 = new AdministratorS();
        administratorS2.setId((Integer) para.get("id"));
        administratorS2.setName((String) para.get("name"));
        administratorS2.setPassword((String) para.get("password"));
        administratorS2.setPhone((String) para.get("phone").toString());
        administratorS2.setSex((String) para.get("sex"));
        administratorS2.setMajor((String) para.get("major"));
        administratorSMapper.updateById(administratorS2);
    }
}
